Database storage reclaiming program

ABSTRACT

The computer retrieves a list of the data elements contained in a database. The computer performs a static and dynamic analysis on the list to determine which data elements have been active in a static or dynamic Structured Query Language (SQL) statement, then removes active data elements from the list. The computer performs a dependency test to determine which data elements on the list are depended on by data objects not on the list and removes those data elements which are depended on. The computer analyzes application code to extract SQL statements and determine whether data elements on the list are active in application code SQL. Any data elements on the list which are active in application code SQL are removed from the list and the remaining data elements on the list are sorted in descending order based on size.

TECHNICAL FIELD

The present invention relates generally to database storage, and moreparticularly to reclaiming database storage.

BACKGROUND

Database storage can be expensive to purchase, maintain, and house.Often times as new business models are integrated into the databasedesign, the data elements that have become redundant or stale are seldomremoved and needlessly consume storage in the database. This may be dueto factors such as complexity of the database, staff turnover,unfamiliarity with the data model, and uncertainty as to whether dataelements can be removed safely without affecting applications orworkloads. Current methods to reclaim database storage includemulti-temperature database storage in which database systems managestorage by ranking rows, or records, of data based on their use,including factors such as frequency of access, age, volatility, andimportance of query performance. Multi-temperature storage systems maystore frequently used data into hot storage, or fast and expensivestorage, while data not frequently used is stored in cold storage, orslower and less expensive storage. The problem with multi-temperaturestorage is that while an entire row, or record, may be considered hotdata, some data elements of the record may not be used as frequently asthe data elements meriting the record designation in hot storage. Forexample, a Department of Motor Vehicles database may contain informationon the registered vehicles of a state. A vehicle record may include hot,or frequently accessed, data such as make and model, but it also mayinclude cold, or less frequently accessed, data such as engine type.Because the record is a single entity, not only is the hot data such asvehicle make and model stored in hot storage, but the cold data such asengine type as well.

SUMMARY

Embodiments of the present invention disclose a method, system, andcomputer program product for a database storage reclaiming system. Thecomputer retrieves a list of the data elements contained in a database.The computer performs a static and dynamic analysis on the list todetermine which data elements have been active in a static or dynamicStructured Query Language (SQL) statement, then removes active dataelements from the list. The computer performs a dependency test todetermine which data elements on the list are depended on by dataobjects not on the list and removes those data elements which aredepended on. The computer analyzes application code to extract SQLstatements and determine whether data elements on the list are active inapplication code SQL. Any data elements on the list which are active inapplication code SQL are removed from the list and the remaining dataelements on the list are sorted in descending order based on size.

BRIEF DESCRIPTION OF THE SEVERAL VIEWS OF THE DRAWING

FIG. 1 illustrates a database storage reclaiming system, in accordancewith an embodiment of the invention.

FIG. 2 is a flowchart illustrating the operations of a database storagereclaiming program of FIG. 1 in determining where and how much storageof a database can be reclaimed, in accordance with an embodiment of theinvention.

FIG. 3 is a block diagram depicting the hardware components of adatabase storage reclaiming system of FIG. 1, in accordance with anembodiment of the invention.

DETAILED DESCRIPTION

Embodiments of the present invention will now be described in detailwith reference to the accompanying figures.

FIG. 1 illustrates a database storage reclaiming system 100, inaccordance with an embodiment of the invention. In the exampleembodiment, the database storage reclaiming system 100 includes databaseserver 110.

Database server 110 includes database 112, database management system114, database catalog 115, and storage reclaiming program 116. In theexample embodiment, database server 110 may be a laptop computer, anotebook, tablet computer, netbook computer, personal computer (PC), adesktop computer, a personal digital assistant (PDA), a smart phone, athin client, or any other electronic device or computing system capableof receiving and sending data to and from other computing devices. Whiledatabase server 110 is shown as a single device, in other embodiments,database server 110 may be comprised of a cluster or plurality ofcomputing devices, working together or working separately. Databaseserver 110 is described in more detail with reference to FIG. 3.

Database 112 is an organized collection of data stored on hard diskspace. In the example embodiment, database 112 is stored locally ondatabase server 110, however in other embodiments database 112 may bestored remotely and accessed via a network.

Database management system (DBMS) 114 is a computer software applicationthat interacts with users via a user interface, other applications, anddatabase 112 to capture and analyze data. DBMS 114 is designed tofacilitate the definition, creation, is querying, update, andadministration of databases. In the example embodiment, databasemanagement system 114 is associated with database 112 and is storedlocally on database server 110. In other embodiments, databasemanagement system may be stored remotely and communicated with via anetwork.

Database catalog 115 is a collection of metadata which stores thedefinitions of the objects contained in database 112. In the exampleembodiment, the metadata contained in database catalog 115 identifiesall of the data elements contained in database 112 as well as therelationships the data elements may have with other objects. In otherembodiments, however, database catalog 115 may contain metadata definingother information about data elements in database 112. In the exampleembodiment, database catalog 115 is stored locally on database server110, however in other embodiments, database catalog 115 may be storedremotely and accessed via a network.

Storage reclaiming program 116 is a software program on database server110 capable of scanning database catalogs, such as database catalog 115,in order to populate a list of candidates for deletion. Storagereclaiming program 116 is additionally capable of performing a staticanalysis of a database by reviewing the static Structured Query Language(SQL) statements and removing any data elements from the list which wereused in a static SQL statement within a relevant period of time.Structured Query Language, or SQL, is a special purpose programminglanguage designed for managing data held in a relational databasemanagement system, such as DBMS 114. Storage reclaiming program 116 isfurther capable of performing a dynamic analysis of a database bymonitoring the database for a relevant period of time and removing anydata elements used in dynamic SQL statements within that relevant periodof time from the list. Storage reclaiming program 116 is additionallycapable of performing an impact and dependency analysis of a database bydetermining whether a data element on the list of candidates fordeletion has a relationship with another object and, if a relationshipexists, removing the data element from the list. Storage reclaimingprogram 116 is additionally capable of determining whether any dataelements on the list of candidates for deletion are found in programapplication codes and, if the data element is used in a programapplication code, removing the data element from the list. Storagereclaiming program 116 is capable of sorting the remaining data elementson the list of candidates for deletion by size. While storage reclaimingprogram 116 is stored locally on database server 110 in the exampleembodiment, storage reclaiming program 116 may be stored remotely andaccessed via a network in other embodiments.

FIG. 2 is a flowchart depicting the operation of storage reclaimingprogram 116 in determining which data elements of a database areinactive and sorting them by size, in accordance with an embodiment ofthe present invention. In the example embodiment where database catalog115 stores metadata relating to database 112, storage reclaiming program116 retrieves a list of candidates for deletion by referencing databasecatalog 115 to retrieve an exhaustive list of every data element storedin database 112, known as the list of candidates for deletion or simplythe list (step 202). Although the resulting list of candidates fordeletion may also include important and/or frequently used dataelements, active data elements may be filtered off of the list asdescribed below.

Storage reclaiming program 116 determines whether data elements on thelist of candidates for deletion are active in static SQL statementswithin the relevant period of time (decision 204). A static SQLstatement is defined as a SQL statement in an application that does notchange at runtime and can be hard-coded into an application. Static SQLstatements are application specific and define the manner in which theapplication interacts with the data elements in database 112. Each timea data element contained in database 112 is active in a static SQLstatement, database management system 114 registers the data element,the date of use, and the time of use. In order to determine which dataelements are active within the relevant time period, storage reclaimingprogram 116 cross references the times and dates of registered dataelement use with the data elements on the list of candidates fordeletion. If a data element has been used in a static SQL statementwithin the relevant period of time (decision 204 “YES” branch), then thedata element is considered active and is removed from the list ofcandidates for deletion (step 206). If a data element has not been usedin a static SQL statement within the relevant period of time (decision204 “NO” branch), the data element is considered inactive and remains onthe list as a candidate for deletion. Because data element use mustfirst be registered before storage reclaiming program 116 can determinewhether the data element is active, the relevant period of time isretroactive and set to one (1) year by default. In other embodiments,however, the period of time can be adjusted by the user to go back asfar as desired.

Storage reclaiming program 116 determines whether any data elements onthe list of candidates for deletion are active in a dynamic SQLstatement over the relevant period of time (decision 208). Unlike staticSQL statements which are hard-coded, dynamic SQL statements areconstructed at runtime and are, therefore, not hard-coded into anapplication nor registered by database management system 114. As aresult, dynamic SQL statements are temporary and must be captured asthey are used and before they are discarded. Therefore, determiningwhether data elements are active in dynamic SQL statements requiresproactively monitoring database 112 for a relevant period of time, aprocess also known as workload monitoring. Workload monitoring involvesrecording all requests made by external clients to database 112 andstoring them in binary files, known as capture files. The capture filescontain relevant information about the client request, such as SQL text,bind values, and transaction information. Storage reclaiming program 116cross references the information obtained by workload monitoring withthe data elements on the list of candidates for deletion to determinewhich data elements are active. The relevant period of time forperforming a dynamic analysis is, by default, six months, however theduration can be varied based on the business. If a data element has beenused in a dynamic SQL statement within the relevant period of time(decision 208 “YES” branch), then the data element is considered anactive data element and is removed from the list (step 210). Conversely,if a data element has not been used in a dynamic SQL statement withinthe relevant period of time (decision 208 “NO” branch), then the dataelement is considered inactive and remains on the list as a candidatefor deletion.

Storage reclaiming program 116 determines if data elements on the listof candidates for deletion maintain a relationship with any dataelements not on the list (decision 212). Storage reclaiming program 116determines whether a relationship exists by cross referencing the dataelements on the list of candidates for deletion with relationshipinformation of the data elements contained in database catalog 115.While the static and dynamic analyses remove from the list any dataelements that have been used directly in an SQL statement, this analysisensures that no data elements on the list are indirectly depended on byanother data element. If a relationship exists (decision 212 “YES”branch), then the data element is considered active and is removed fromthe list (step 214). If storage reclaiming program 116 determines thatno relationship exists (decision 212 “NO” branch), the data elementremains on the list as a candidate for deletion. For example, a foreignkey may be present on the list of candidates for deletion even though itmay be a necessary reference for other applications to operate properly.Storage reclaiming program 116 identifies that the foreign key isdepended on by another data element and removes the data elementcorresponding to the foreign key from the list of candidates fordeletion. Another example may include a View object which referencesdata elements in the columns of a table, creating a relationship betweenthe View object and referenced data elements in the columns of thetable. Furthermore, a Trigger object may maintain a relationship with aset of SQL statements that are triggered when a particular SQL operationoccurs, such as adding a date automatically.

Storage reclaiming program 116 determines whether any data elements onthe list of candidates for deletion are used in application code(decision 216). The application code a user wishes to analyze arespecified by user input via a user interface on database server 110 suchthat the user may choose to analyze only the important and frequentlyused applications for a quicker analysis or, conversely, the user maychoose to analyze every application contained on database server 110.Storage reclaiming program 116 determines whether a data element on thelist is used in application code by analyzing the user selectedapplication code and workload logic to extract SQL statements and thencross referencing them with the data elements on the list of candidatesfor deletion. Similar to an impact and dependency analysis, performing acode inspection ensures that although no data elements on the list areused directly in an SQL statement, the data element is also not dependedon or in a relationship with a program application. If a data element onthe list of candidates for deletion is used in the SQL statements ofrelevant application code (decision 216 “YES” branch), then the dataelement is considered active and is removed from the list (step 218). Ifa data element is not used in any relevant application code (decision216 “NO” branch), then the data element is considered inactive andremains on the list of candidates for deletion.

Storage reclaiming program 116 sorts the remaining data elements on thelist of candidates for deletion by size (step 220). In the exampleembodiment, the list of candidates for deletion is sorted in descendingorder such that the data elements providing the most potential memory toreclaim through deletion are display first. In other embodiments, thelist may be sorted based on other factors.

FIG. 3 depicts a block diagram of components of database server 110 of adatabase storage reclaiming program system 100 of FIG. 1, in accordancewith an embodiment of the present invention. It should be appreciatedthat FIG. 3 provides only an illustration of one implementation and doesnot imply any limitations with regard to the environments in whichdifferent embodiments may be implemented. Many modifications to thedepicted environment may be made.

Database server 110 may include one or more processors 302, one or morecomputer-readable RAMs 304, one or more computer-readable ROMs 306, oneor more computer readable storage media 308, device drivers 312,read/write drive or interface 314, network adapter or interface 316, allinterconnected over a communications fabric 318. Communications fabric318 may be implemented with any architecture designed for passing dataand/or control information between processors (such as microprocessors,communications and network processors, etc.), system memory, peripheraldevices, and any other hardware components within a system.

One or more operating systems 310, and one or more application programs311, for example, storage reclaiming program 116, are stored on one ormore of the computer readable storage media 308 for execution by one ormore of the processors 302 via one or more of the respective RAMs 304(which typically include cache memory). In the illustrated embodiment,each of the computer readable storage media 308 may be a magnetic diskstorage device of an internal hard drive, CD-ROM, DVD, memory stick,magnetic tape, magnetic disk, optical disk, a semiconductor storagedevice such as RAM, ROM, EPROM, flash memory or any othercomputer-readable tangible storage device that can store a computerprogram and digital information.

Database server 110 may also include a R/W drive or interface 314 toread from and write to one or more portable computer readable storagemedia 326. Application programs 311 on database server 110 may be storedon one or more of the portable computer readable storage media 326, readvia the respective R/W drive or interface 314 and loaded into therespective computer readable storage media 308.

Database server 110 may also include a network adapter or interface 316,such as a TCP/IP adapter card or wireless communication adapter (such asa 4G wireless communication adapter using OFDMA technology). Applicationprograms 311 on database server 110 may be downloaded to the computingdevice from an external computer or external storage device via anetwork (for example, the Internet, a local area network or other widearea network or wireless network) and network adapter or interface 316.From the network adapter or interface 316, the programs may be loadedonto computer readable storage media 308. The network may comprisecopper wires, optical fibers, wireless transmission, routers, firewalls,switches, gateway computers and/or edge servers.

Database server 110 may also include a display screen 320, a keyboard orkeypad 322, and a computer mouse or touchpad 324. Device drivers 312interface to display screen 320 for imaging, to keyboard or keypad 322,to computer mouse or touchpad 324, and/or to display screen 320 forpressure sensing of alphanumeric character entry and user selections.The device drivers 312, R/W drive or interface 314 and network adapteror interface 316 may comprise hardware and software (stored on computerreadable storage media 308 and/or ROM 306).

The programs described herein are identified based upon the applicationfor which they are implemented in a specific embodiment of theinvention. However, it should be appreciated that any particular programnomenclature herein is used merely for convenience, and thus theinvention should not be limited to use solely in any specificapplication identified and/or implied by such nomenclature.

Based on the foregoing, a computer system, method, and computer programproduct have been disclosed. However, numerous modifications andsubstitutions can be made without deviating from the scope of thepresent invention. Therefore, the present invention has been disclosedby way of example and not limitation.

Various embodiments of the present invention may be a system, a method,and/or a computer program product. The computer program product mayinclude a computer readable storage medium (or media) having computerreadable program instructions thereon for causing a processor to carryout aspects of the present invention.

The computer readable storage medium can be a tangible device that canretain and store instructions for use by an instruction executiondevice. The computer readable storage medium may be, for example, but isnot limited to, an electronic storage device, a magnetic storage device,an optical storage device, an electromagnetic storage device, asemiconductor storage device, or any suitable combination of theforegoing. A non-exhaustive list of more specific examples of thecomputer readable storage medium includes the following: a portablecomputer diskette, a hard disk, a random access memory (RAM), aread-only memory (ROM), an erasable programmable read-only memory (EPROMor Flash memory), a static random access memory (SRAM), a portablecompact disc read-only memory (CD-ROM), a digital versatile disk (DVD),a memory stick, a floppy disk, a mechanically encoded device such aspunch-cards or raised structures in a groove having instructionsrecorded thereon, and any suitable combination of the foregoing. Acomputer readable storage medium, as used herein, is not to be construedas being transitory signals per se, such as radio waves or other freelypropagating electromagnetic waves, electromagnetic waves propagatingthrough a waveguide or other transmission media (e.g., light pulsespassing through a fiber-optic cable), or electrical signals transmittedthrough a wire.

Computer readable program instructions described herein can bedownloaded to respective computing/processing devices from a computerreadable storage medium or to an external computer or external storagedevice via a network, for example, the Internet, a local area network, awide area network and/or a wireless network. The network may comprisecopper transmission cables, optical transmission fibers, wirelesstransmission, routers, firewalls, switches, gateway computers and/oredge servers. A network adapter card or network interface in eachcomputing/processing device receives computer readable programinstructions from the network and forwards the computer readable programinstructions for storage in a computer readable storage medium withinthe respective computing/processing device.

Computer readable program instructions for carrying out operations ofthe present invention may be assembler instructions,instruction-set-architecture (ISA) instructions, machine instructions,machine dependent instructions, microcode, firmware instructions,state-setting data, or either source code or object code written in anycombination of one or more programming languages, including an objectoriented programming language such as Java, Smalltalk, C++ or the like,and conventional procedural programming languages, such as the “C”programming language or similar programming languages. The computerreadable program instructions may execute entirely on the user'scomputer, partly on the user's computer, as a stand-alone softwarepackage, partly on the user's computer and partly on a remote computeror entirely on the remote computer or server. In the latter scenario,the remote computer may be connected to the user's computer through anytype of network, including a local area network (LAN) or a wide areanetwork (WAN), or the connection may be made to an external computer(for example, through the Internet using an Internet Service Provider).In some embodiments, electronic circuitry including, for example,programmable logic circuitry, field-programmable gate arrays (FPGA), orprogrammable logic arrays (PLA) may execute the computer readableprogram instructions by utilizing state information of the computerreadable program instructions to personalize the electronic circuitry,in order to perform aspects of the present invention.

Aspects of the present invention are described herein with reference toflowchart illustrations and/or block diagrams of methods, apparatus(systems), and computer program products according to embodiments of theinvention. It will be understood that each block of the flowchartillustrations and/or block diagrams, and combinations of blocks in theflowchart illustrations and/or block diagrams, can be implemented bycomputer readable program instructions.

These computer readable program instructions may be provided to aprocessor of a general purpose computer, special purpose computer, orother programmable data processing apparatus to produce a machine, suchthat the instructions, which execute via the processor of the computeror other programmable data processing apparatus, create means forimplementing the functions/acts specified in the flowchart and/or blockdiagram block or blocks. These computer readable program instructionsmay also be stored in a computer readable storage medium that can directa computer, a programmable data processing apparatus, and/or otherdevices to function in a particular manner, such that the computerreadable storage medium having instructions stored therein comprises anarticle of manufacture including instructions which implement aspects ofthe function/act specified in the flowchart and/or block diagram blockor blocks.

The computer readable program instructions may also be loaded onto acomputer, other programmable data processing apparatus, or other deviceto cause a series of operational steps to be performed on the computer,other programmable apparatus or other device to produce a computerimplemented process, such that the instructions which execute on thecomputer, other programmable apparatus, or other device implement thefunctions/acts specified in the flowchart and/or block diagram block orblocks.

The flowchart and block diagrams in the figures illustrate thearchitecture, functionality, and operation of possible implementationsof systems, methods, and computer program products according to variousembodiments of the present invention. In this regard, each block in theflowchart or block diagrams may represent a module, segment, or portionof instructions, which comprises one or more executable instructions forimplementing the specified logical function(s). In some alternativeimplementations, the functions noted in the block may occur out of theorder noted in the figures. For example, two blocks shown in successionmay, in fact, be executed substantially concurrently, or the blocks maysometimes be executed in the reverse order, depending upon thefunctionality involved. It will also be noted that each block of theblock diagrams and/or flowchart illustration, and combinations of blocksin the block diagrams and/or flowchart illustration, can be implementedby special purpose hardware-based systems that perform the specifiedfunctions or acts or carry out combinations of special purpose hardwareand computer instructions.

What is claimed is:
 1. A computer system for a database storagereclaiming program, the computer system comprising: one or more computerprocessors, one or more computer-readable storage media, and programinstructions stored on one or more of the computer-readable storagemedia for execution by at least one of the one or more processors, theprogram instructions comprising: program instructions to retrieve a listof one or more data elements contained in a database; programinstructions to detect utilization of a first data element on the listof one or more data elements in a static Structured Query Language (SQL)statement; based on detecting utilization of the first data element onthe list of one or more data elements in a static SQL statement, programinstructions to create a record associated with the first data elementdetailing a time at which the first data element was utilized in thestatic SQL statement; program instructions to detect utilization of asecond data element on the list of one or more data elements in adynamic SQL statement; based on detecting utilization of the second dataelement on the list of one or more data elements in a dynamic SQLstatement, program instructions to create a capture file associated withthe second data element detailing a time at which the second dataelement was utilized in the dynamic SQL statement; program instructionsto receive a retroactive time period from a user; program instructionsto determine whether the first data element has been utilized in thestatic SQL statement within the retroactive time period by comparing thetime detailed by the record with the retroactive time period; based ondetermining that the first data element has been utilized in a staticSQL statement within the retroactive time period, program instructionsto remove the first data element from the list of one or more dataelements; program instructions to determine whether the second dataelement has been utilized in the dynamic SQL statement within theretroactive time period by comparing the time detailed by the capturefile with the retroactive time period; based on determining that thesecond data element has been utilized in the dynamic SQL statementwithin the retroactive time period, program instructions to remove thesecond data element from the list of one or more data elements; programinstructions to receive a list of one or more applications from theuser; program instructions to analyze application code associated witheach of the one or more applications to extract one or more applicationcode SQL statements; program instructions to determine whether a thirddata element on the list of one or more data elements has been utilizedin the extracted one or more application code SQL statements within theretroactive time period; based on determining that the third dataelement on the list of one or more data elements has been utilized inthe one or more application code SQL statements within the retroactivetime period, program instructions to remove the third data element fromthe list of one or more data elements.